package deng.ejb3.examples.simplecase.client;

import javax.jms.Connection;
import javax.naming.Context;

public class MainHelper {
	
	public static void close(Context namingContext) {
		if (namingContext != null) {
			try {
				namingContext.close(); 
			} catch (Exception e) {
				throw new RuntimeException("Failed to close naming context: " + namingContext, e);
			} 
		}
	}

	
	public static void close(Connection jmsConnection) {
		if (jmsConnection != null) {
			try {
				jmsConnection.close(); 
			} catch (Exception e) {
				throw new RuntimeException("Failed to close jms connection: " + jmsConnection, e);
			} 
		}
	}
	
	public static void sleep(long milliseconds) {
		try {
			Thread.sleep(milliseconds);
		} catch (Exception e) {
			throw new RuntimeException("Failed to sleep for milliseconds: " + milliseconds);
		} 
	}
	
}
